Passed
Push — master ( 33081a...0dd98d )
by Paul
05:28
created

pointers.js ➔ Pointers   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
1
/** global: GLSR, jQuery */
2
;(function( x ) {
3
4
	'use strict';
5
6
	var Pointers = function() {
7
		x.each( GLSR.pointers, function( i, pointer ) {
8
			this.init_( pointer );
9
		}.bind( this ));
10
	};
11
12
	Pointers.prototype = {
13
		/** @return void */
14
		close_: function( pointerId ) { // string
15
			x.post( GLSR.ajaxurl, {
16
				pointer: pointerId,
17
				action: 'dismiss-wp-pointer',
18
			});
19
		},
20
21
		/** @return void */
22
		init_: function( pointer ) { // object
23
			x( pointer.target ).pointer({
24
				content: pointer.options.content,
25
				position: pointer.options.position,
26
				close: this.close_.bind( pointer.id ),
27
			})
28
			.pointer( 'open' )
29
			.pointer( 'sendToTop' );
30
			x( document ).on( 'wp-window-resized', function() {
31
				x( pointer.target ).pointer( 'reposition' );
32
			});
33
		},
34
	};
35
36
	GLSR.Pointers = Pointers;
37
})( jQuery );
38